package logic

import (
	"context"
	"fmt"

	"go-pod/pod-rpc/internal/svc"
	"go-pod/pod-rpc/pod"

	"github.com/zeromicro/go-zero/core/logx"
)

type DeletePodcastLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewDeletePodcastLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeletePodcastLogic {
	return &DeletePodcastLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// DeletePodcast 删除播客
func (l *DeletePodcastLogic) DeletePodcast(in *pod.DeletePodcastReq) (*pod.DeletePodcastResp, error) {
	// 删除播客记录
	err := l.svcCtx.PodcastModel.Delete(l.ctx, uint64(in.Id))
	if err != nil {
		return nil, fmt.Errorf("删除播客失败: %w", err)
	}

	return &pod.DeletePodcastResp{}, nil
}
